This invention is a new programmable minimal-context process able to perform any kernel function, including the efficient servicing of system interrupts and other events. This background section discusses process context and servicing of interrupts as implemented in prior art kernel-based operating systems. More information about these topics is available in chapters 6 and 12 of "The Design of the UNIX Operating System," written by Maurice J. Bach, and published in 1986 by Prentice-Hall, Inc.
In current kernel-based systems, all processes are created equal. That is, every process is assigned the same background elements of context when it is created. Process context has two components, user-side context and system-side context.
User-side context consists of the process instructions, its data, its stack, any shared data, and the contents of any user-related registers. The system-side context consists of the process table entry containing state, accounting, scheduling and general control information, internal process control information, the kernel stack, and the contents of system-related registers.
The kernel must save the register portion of the context of a process whenever a process is switched out of execution, and restore that portion of the context prior to the processor's resuming execution. Switching register contexts can take a substantial number of processor cycles depending upon how many registers are implemented in a system architecture. Scalar/vector processors having several multifunction functional units usually require significant numbers of scalar registers, large capacity vector registers, and storage registers as do systems in which data is frequently shared. These cycles impact system performance because register context switches are done each time the system receives an interrupt, the kernel does a process switch, or when a user makes a system call. To switch one process out and another process in requires the current process's register context to be saved, and the next process's register context to be restored. After that process executes, its register context will be saved and another process's context will be restored. When processes are interrupted, or system calls made, the user register context must be saved to allow the system to use the system registers. The user register context must then be restored prior to returning control of the processor to the user. When the processes involved in such switches are processes executing user programs, the overhead of context switching and creation is justified since user processes require all that context to do work. However, a significant number of processes do only system or kernel work. These kernel processes carry some amounts of unnecessary context, and therefore take longer to create and to switch than they actually need to take. There is a need in the prior art to develop a method by which kernel functions are performed more efficiently and consume only the processor resources absolutely required.
The servicing of system interrupts in prior art systems provides an example of a common kernel function in which a quicker and more efficient method is desired. In these systems the kernel does work resulting from the arrival of an interrupt at a particular processor by stopping the process currently executing on the processor. The work is done in the context of the currently executing process.
Process A is running when an interrupt occurs, for example, an I/O interrupt confirms that a disk transfer has been made to memory for Process X. Process A is interrupted because of process X. Interrupt hardware transfers control to the zero level interrupt handling routine.
On the software side, the interrupt handler first saves the register context of process A and sets a pointer to process A's process number to start it up again later. The process A information originally stored in the stack may be moved to a temporary stack, although many prior art implementations use the kernel stack.
The interrupt handler now wakes up Process X. Process X has been blocked from any other activity while it has been waiting for the interrupt handler to respond. The wake up call unblocks Process X and queues it on the run queue. If there is now a higher priority process on the run queue, the interrupt handler being run by Process A calls the integrated dispatcher and the highest priority process is chosen to run. This process may be Process X or some other process that has been queued at a higher priority. If a higher priority process does not exist can the run queue, the interrupt handler does not invoke the integrated dispatcher. Instead, Process A's context is restored and it resumes execution.
The performance of kernel functions such as interrupt handling in prior art systems has several basic problems. A major problem is the amount of system overhead required to perform kernel functions. Context switches and process start-up times consume processor cycles and affect the overall performance of the processor. Efficiency is reduced because of overhead associated with processes. In a classical Unix implementation, only one kind of process entity can be created or processed by only one kind of creating entity, the fork system call. As a result, the kernel processes contain more context information than is actually required. The user-side context of kernel processes (i.e., user block and various process table fields) is ignored by the system and is not used. However, even though it is unused, user-side context does have overhead associated with memory and switching because the system automatically processes this context and unnecessarily consumes resources to do so.
Another problem with existing implementations is that when an interrupt occurs, the processor which receives the interrupt stops processing to handle the interrupt, regardless of what the processor was doing. This can result in delaying a high priority task by making the processor service a lower priority interrupt. Prior art methods cannot prevent lower priority processes from interrupting higher priority processes and, in fact, it is common for high priority processes to be routinely interrupted by lower priority processes.
Forcing the currently executing process to handle interrupts creates problems in resource accounting. The accounting of processor time for kernel functions in prior art methods is not accurate since the currently running process is charged for the processor time while it services another process's interrupt. In the example above, process A will be charged for the processor time required to service the interrupt for process X.
Additionally, the prior art provides a method designed to be implemented on single processor systems. Deficiencies in the prior art are apparent when a kernel function such as interrupt handling is implemented on multiprocessor systems. In a single processor system, the interrupt is handled by default on the only processor. In multiprocessor systems, it may be desirable to service the interrupt on a preferred processor, on one doing lower priority work, for example, or on an idle processor.